package com.wenjunwu.blog.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.wenjunwu.blog.common.BaseDao;
import com.wenjunwu.blog.dao.SystemUserDao;
import com.wenjunwu.blog.entity.SystemUser;

@Repository
public class SystemUserDaoImpl extends BaseDao<SystemUser> implements SystemUserDao {

	@Override
	public SystemUser findUser(Long id) {
		return sqlSession.selectOne(DEFAULTNAMESPACE.concat("selectById"), id);
	}

	@Override
	public SystemUser findUser(String username) {
		return sqlSession.selectOne(DEFAULTNAMESPACE.concat("selectByUsername"), username);
	}

	@Override
	public List<SystemUser> findUsers() {
		return sqlSession.selectList(DEFAULTNAMESPACE.concat("selectAllUsers"));
	}

	@Override
	public List<SystemUser> findUsersPage(Map<String, Object> params) {
		return sqlSession.selectList(DEFAULTNAMESPACE.concat("selectUsersPage"), params);
	}

	@Override
	public int insert(SystemUser systemUser) {
		return sqlSession.insert(DEFAULTNAMESPACE.concat("insert"), systemUser);
	}

	@Override
	public int update(SystemUser systemUser) {
		return sqlSession.update(DEFAULTNAMESPACE.concat("updateById"), systemUser);
	}

	@Override
	public int deleteUserById(long id) {
		return sqlSession.delete(DEFAULTNAMESPACE.concat("deleteUserById"), id);
	}
}
